package com.starview.star.operators.general.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.Refresher;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.type.TypeVar;
import com.starview.star.operators.CafeEnter;

public class Raise implements IFunction
{
  public static final String name = "__raise";

  @CafeEnter
  public static IValue enter(EvaluationException msg) throws EvaluationException
  {
    throw msg;
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter((EvaluationException)args[0]);
  }

  @Override
  public IType getType()
  {
    return type();
  }

  public static IType type()
  {
    return Refresher.generalize(TypeUtils.functionType(StandardTypes.exceptionType, new TypeVar()));
  }
}
